# _*_ coding: utf-8 _*_
# @Author   : Wei Yue
# @Time     : 2023-05-16 17:24
# @Function : 一些通用值和常用变换
import math
pi = 3.14159265359

def dq2abc(d_value,q_value,theta):
    a_value = d_value * math.cos(theta) - q_value * math.sin(theta)
    b_value = d_value * math.cos(theta - 2 * pi / 3) - q_value * math.sin(theta - 2 * pi / 3)
    c_value = d_value * math.cos(theta + 2 * pi / 3) - q_value * math.sin(theta + 2 * pi / 3)
    return a_value,b_value,c_value

def spd2we(spd,p):
    return spd * pi/30 *p

def sign(x):
    if x >0:
        return 1
    elif x==0:
        return 0
    else:
        return -1

